package com.my.aslife.controller;

import com.my.aslife.module.common.ErrorCode;
import com.my.aslife.module.common.ResponseResult;
import com.my.aslife.module.entity.dtos.CommentDto;
import com.my.aslife.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author mayuan
 * @description TODO
 */
@RestController
@RequestMapping("/api/my/comment")
@Slf4j
public class CommentController {

    @Autowired
    private CommentService commentService;

    @PostMapping("/push/comment")
    public ResponseResult pushComment(@RequestBody CommentDto commentDto){
        if (commentDto.getComment() == null || commentDto.getOrderId() == null) {
            return ResponseResult.failed(ErrorCode.C_PARAMS_NOT_NULL);
        }
        return commentService.pushComment(commentDto);
    }

    @PostMapping("/get/comment/{orderId}")
    public ResponseResult getComment(@PathVariable Long orderId){
        return commentService.getComment(orderId);
    }

}
